package com.yuncool.mq.consumer;

import com.yuncool.constants.RabbitQueue;
import com.yuncool.domain.vo.EmailRequestCodeVO;
import com.yuncool.domain.vo.SmsRequestVO;
import com.yuncool.service.EmailService;
import com.yuncool.service.SmsService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Auther XIE
 * @Date 2019/8/25 17:12
 * @Description 邮件队列消费者
 * @Version 1.0
 */
@Component
public class EmailConsumer {
    @Autowired
    private EmailService emailService;

    /**
     * 邮件验证码消费者
     * @param emailRequestCodeVO
     */
    @RabbitListener(queues = RabbitQueue.MAIL_QUEUE_CODE)
    @RabbitHandler
    public void receiveSmsQueue(EmailRequestCodeVO emailRequestCodeVO){
        emailService.sendEmail(emailRequestCodeVO);
    }
}
